package com.itheima.test2;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;

/**
 * @Author:gy
 * @Date: 2025/09/04 9:06
 * @Description:
 */
public class ClentDemo {
    public static void main(String[] args) throws Exception {
        //找到一个码头
        DatagramSocket ds = new DatagramSocket();
        //礼物打包
        String s = "hello主播";
        byte[] buf = s.getBytes();
        //写成往主播发送的地址 单机ip换成一个组的ip
        InetAddress ip = InetAddress.getByName("224.0.1.0");
        int port = 10010;
        DatagramPacket dp = new DatagramPacket(buf, buf.length, ip, port);
        ds.send(dp);
        ds.close();
    }
}
